﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using Server_NhaSach.DataTransferObject;
using Server_NhaSach.DataAccess.LogicLayer;

namespace Server_NhaSach.BusinessLayer
{
    [Serializable]
    public class LoaiHangBlo
    {
        #region "Khai báo các biến"
        private LoaiHangDAO da;
        private LoaiHangDTO _LoaiHang;
        private string _error;
        #endregion

        #region "Khai báo các thuộc tính"
        public string Error
        {
            get { return _error; }
        }
        public LoaiHangDTO LoaiHang
        {
            get { return _LoaiHang; }
            set { _LoaiHang = value; }
        }
        #endregion

        #region "Khai báo các Method"
        public LoaiHangBlo()
        {
            _LoaiHang = new LoaiHangDTO();
            da = new LoaiHangDAO();
        }
        public bool InsertLoaiHang(string MaLoai, string TenLoai)
        {
            LoaiHang = new LoaiHangDTO(MaLoai, TenLoai);
            if (!da.InserLoaiHang(LoaiHang))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool UpdateLoaiHang(string MaLoai, string TenLoai)
        {
            LoaiHang = new LoaiHangDTO(MaLoai, TenLoai);
            if (!da.UpdateLoaiHang(LoaiHang))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool DeleteLoaiHang(string MaLoai)
        {
            if (!da.DeletLoaiHang(MaLoai))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public DataSet LayDS_LoaiHang()
        {
            DataSet ds = new DataSet();
            ds = da.LayDS_LoaiHang();
            return ds;
        }
        #endregion
    }
}